////
//
/// \file ./include/inc/parser/utilities.hpp
//
//  Copyright 2008 Chandler Carruth
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations
//  under the License.
//
////

#ifndef     inc_parser_filename_header_
#define     inc_parser_filename_header_

namespace inc {
namespace parser {

/// \brief  Compute the length of a constant size array
/// \author Chandler Carruth
/// \date   2008.04.30
///
/// This is a magical macro which will determine the length in elements of
/// a compile-time constant size array. It will do so at *compile time*,
/// allowing use in specifying other constant size arrays.

// This declares an undefined function returning the element type. Using this
// template induces a compiler error if a non-constant sized array is used. It
// is never defined, but the return type doesn't require evaluating the actual
// function call, so the sizeof() reduces at compile time.
template< typename T, size_t N > T extract_element_type__( T (&x)[N] );
#define elementsof(x) \
    ( sizeof(x) / sizeof(extract_element_type__(x)) )

} // end parser namespace
} // end inc namespace
#endif  //  inc_parser_filename_header_
